package com.chushouya.manager.constants;


import com.general.framework.core.enums.IEnum;
import com.general.framework.core.exception.Ex;
import com.general.framework.core.lang.Lists;
import com.general.framework.core.lang.Strings;

import java.util.List;
import java.util.Objects;


public enum SettleBizTypeSimpleEnum implements IEnum<Integer> {
    RECHARGE(1, "充值", Lists.asList(
            SettleBizTypeEnum.MERCHANT_RECHARGE.value()
    )),
    WITHDRAW(2, "提现", Lists.asList(
            SettleBizTypeEnum.STORE_WITHDRAW.value()
    )),
    COMMISSION(4, "佣金", Lists.asList(
            SettleBizTypeEnum.STORE_COMMISSION.value()
    )),
    ;

    private Integer bizTypeSimple;

    private String desc;

    private List<Integer> bizTypes;

    SettleBizTypeSimpleEnum(Integer bizTypeSimple, String desc, List<Integer> bizTypes) {
        this.bizTypeSimple = bizTypeSimple;
        this.desc = desc;
        this.bizTypes = bizTypes;
    }

    public static String getDesc(Integer bizTypeSimple) {
        for (SettleBizTypeSimpleEnum thisEnum : SettleBizTypeSimpleEnum.values()) {
            if (Objects.equals(thisEnum.bizTypeSimple, bizTypeSimple)) {
                return thisEnum.desc;
            }
        }
        return Strings.EMPTY;
    }

    public static SettleBizTypeSimpleEnum get(Integer bizTypeSimple) {
        for (SettleBizTypeSimpleEnum thisEnum : SettleBizTypeSimpleEnum.values()) {
            if (Objects.equals(thisEnum.bizTypeSimple, bizTypeSimple)) {
                return thisEnum;
            }
        }
        throw Ex.systemError("未定义的结算类型[{}]", bizTypeSimple);
    }

    @Override
    public Integer value() {
        return this.bizTypeSimple;
    }

    @Override
    public String named() {
        return this.desc;
    }

    public List<Integer> getBizTypes() {
        return bizTypes;
    }
}
